<#import "/macro.ftl" as m>
<@m.page_header title='添加推广' />
<div id="page-content-wrapper">
    <div id="page-title">
        <h3><a href="/popularizes" class="font-blue">推广列表</a> > 添加推广</h3>
    </div>
    <div id="page-content">
    	<#if error??>
    		<div class="infobox error-bg mrg10B">${error}</div>
    	</#if>
    	<form id="form" method="post" action="/popularizes">
    		<div class="form-row">
                <div class="form-label col-md-2">
                    <label for="name">名称:</label>
                </div>
                <div class="form-input col-md-10">
                    <input placeholder="" type="text" id="name" name="name" value="${popularize.name}" data-required="true" data-rangelength="[1,45]">
                </div>
	        </div>
	        <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="category.id">类别:</label>
                </div>
                <div id="select" class="form-input col-md-10">
                	<select data-placeholder="选择类别" name="category.id" class="chosen-select" style="display: none;">
	                	<#list categorys as category>
	                		<#if category.id == popularize.category.id>
	                			<#assign selected="selected">
	                		<#else>
	                			<#assign selected="">
	                		</#if>
				            <option value="${category.id}" ${selected}>${category.name} - ${category.bigger.name}</option>
						</#list>
					</select>
                </div>
            </div>
            <div class="form-row">
                <div class="form-label col-md-2">
                    <label for="url">推广URL:</label>
                </div>
                <div class="form-input col-md-10">
                    <input placeholder="" type="text" id="url" name="url" value="${popularize.url}" data-required="true" data-rangelength="[1,256]">
                </div>
	        </div>
            <div class="form-row">
                <div class="form-label col-md-12">
                    <a href="javascript:;" class="btn medium primary-bg radius-all-4 float-right" onclick="submit();" title="Validate!">
		                <span class="button-content">保存</span>
		            </a>
                </div>
            </div>
    	</form>
    </div>
</div>
<script>
function submit(){
	if( $('#form' ).parsley( 'validate' ) ){
		$('#form' ).submit();
	}
}
</script>